#ifndef _Hash_H
#define _Hash_H
#include <Ntifs.h>
#include <ntddk.h>
#include <ntstrsafe.h>


typedef unsigned char BYTE;
typedef unsigned long DWORD;
typedef unsigned short WORD;


typedef struct _ELEMENT
{
	PVOID		pData;
	ULONG		ulSize;
} ELEMENT, *PELEMENT;

typedef struct _TWOWAY
{
	DWORD key;
	ELEMENT data;
	LIST_ENTRY linkfield;
} TWOWAY, *PTWOWAY;

typedef struct _HASHTABLE
{
	unsigned int	tableSize;
	ERESOURCE		resource;
	PLIST_ENTRY		pListHeads;
	PAGED_LOOKASIDE_LIST LookasideList_TWOWAY;
} HASHTABLE, *PHASHTABLE;
typedef struct _HASHTABLE HASHTABLE, *PHASHTABLE;

PHASHTABLE InitializeTable(unsigned int tableSize);
BOOLEAN Insert(DWORD key, PELEMENT pData, PHASHTABLE pHashTable);
BOOLEAN Remove(DWORD key, PHASHTABLE pHashTable);
void DestroyTable(PHASHTABLE pHashTable);
ULONG GetTableCount(PHASHTABLE pHashTable);
void	LockRead(PHASHTABLE pHashTable);
void	LockWrite(PHASHTABLE pHashTable);
void	UnLock(PHASHTABLE pHashTable);

#endif 
